<template>
  <div id=content>
      <h2>学生名字：{{studentObj.name}}</h2>
      <h2>学生年龄：{{studentObj.age}}</h2>
      <h2>学生性别：{{studentObj.sex}}</h2>
      <button @click="sendStudent">测试组件间通信【全局事件总线】</button>
  </div>
</template>

<script>
    export default {
        name:'Students',
        data (){
            return {
                studentObj:{
                    name:'涨停三',
                    age:14,
                    sex:'男'
                }
            }
        },
        methods: {
            sendStudent() {
                // 借助$bus 触发已注册的全局事件
                this.$bus.$emit('hello', JSON.stringify(this.studentObj))
            }
        },
        
    }
</script>

<style scoped>
    #content {
        background-color: pink;
        padding:5px 10px;
        margin: 10px;
    }
</style>